#ifndef BINVIEW_H
#define BINVIEW_H

#include <QMainWindow>
#include <QTableView>
#include "tablemodel.h"
#include "types.h"
#include <QPoint>
#include <QByteArray>
#include <QDebug>
#include <QTableWidget>

namespace Ui {
class BinView;
}

class BinView : public QMainWindow
{
    Q_OBJECT

public:
    explicit BinView(QByteArray data, QWidget *parent = 0);
    ~BinView();

public slots:
    void onSelectChange(QModelIndex index);
    void setAddrFormat(DISPLAY_FORMAT_EN format);
    void setFirstFormat(DISPLAY_FORMAT_EN format);
    void setSecFormat(DISPLAY_FORMAT_EN format);
    void setFirstEndian(DISPLAY_ENDIAN_EN format);
    void setSecEndian(DISPLAY_ENDIAN_EN format);

    bool hasValidIndex();

    void bookmarkDoubleClick(int x, int y);
    void searchResultClick(int x, int y);

    void showBookmark();
    void showSearchResult();
    void addBookmark(QString title, QString remark);

    void search(QByteArray bytes, int searchType, bool current);

    void onSearchResult(int index);
    void onSearchEnd(int count, int start);

    void gotoLine(int index);


private:
    Ui::BinView *ui;
    TableModel *model;
    QModelIndex currentIndex;
    QList<QModelIndex> bookmarkList;
    QList<QByteArray> searchContentList;
    QList<bool> searchTypeList;
    QList<int> searchAddrList;
    QList<QTableWidget *> searchRViewList;

    QPoint byte1ASCII;
    QPoint byte1BIN;
    QPoint byte1HEX;
    QPoint byte1INT;
    QPoint byte1UINT;
    QPoint byte1OCT;

    QPoint byte2BIN;
    QPoint byte2HEX;
    QPoint byte2INT;
    QPoint byte2UINT;
    QPoint byte2OCT;

    QPoint byte4BIN;
    QPoint byte4HEX;
    QPoint byte4INT;
    QPoint byte4UINT;
    QPoint byte4OCT;

    QPoint byte8BIN;
    QPoint byte8HEX;
    QPoint byte8INT;
    QPoint byte8UINT;
    QPoint byte8OCT;

    QPoint byte1BASCII;
    QPoint byte1BBIN;
    QPoint byte1BHEX;
    QPoint byte1BINT;
    QPoint byte1BUINT;
    QPoint byte1BOCT;

    QPoint byte2BBIN;
    QPoint byte2BHEX;
    QPoint byte2BINT;
    QPoint byte2BUINT;
    QPoint byte2BOCT;

    QPoint byte4BBIN;
    QPoint byte4BHEX;
    QPoint byte4BINT;
    QPoint byte4BUINT;
    QPoint byte4BOCT;

    QPoint byte8BBIN;
    QPoint byte8BHEX;
    QPoint byte8BINT;
    QPoint byte8BUINT;
    QPoint byte8BOCT;
};

#endif // BINVIEW_H
